package com.example.springamqpconsumer.lister;

import com.example.springamqpconsumer.utils.AliCodeUtils;
import org.springframework.amqp.core.Message;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.stereotype.Service;

import java.util.concurrent.TimeUnit;

@Service
public class ConsumerLister {
    @Autowired
    private StringRedisTemplate stringReditsTemplate;
    @RabbitListener(queues = "java-queue")
    public void getMsg(Message message,String phone) throws Exception {
        System.out.println("我接收到了消息"+phone);
        AliCodeUtils aliCodeUtils = new AliCodeUtils();
        aliCodeUtils.senLoginCode(phone, "123456");
        stringReditsTemplate.opsForValue().set(phone, "123456");
        stringReditsTemplate.expire(phone, 1, TimeUnit.MINUTES);

    }

}

